@rvoh/dream 0.32.4 → 0.34.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 (279) hide show
  1. package/dist/cjs/src/Dream.js +1 -1
  2. package/dist/cjs/src/bin/helpers/sync.js +2 -2
  3. package/dist/cjs/src/dream-application/helpers/DreamImporter.js +0 -5
  4. package/dist/cjs/src/dream-application/helpers/lookupClassByGlobalName.js +0 -2
  5. package/dist/cjs/src/dream-application/index.js +4 -10
  6. package/dist/cjs/src/helpers/DreamGlam/howyadoins/whaaaaaaaaaaok.js +2 -2
  7. package/dist/cjs/src/helpers/cli/SchemaBuilder.js +2 -2
  8. package/dist/cjs/src/helpers/cli/autoGeneratedFileDisclaimer.js +33 -0
  9. package/dist/cjs/src/helpers/loadRepl.js +3 -5
  10. package/dist/cjs/src/helpers/path/dreamPath.js +0 -2
  11. package/dist/cjs/src/index.js +3 -4
  12. package/dist/esm/src/Dream.js +1 -1
  13. package/dist/esm/src/bin/helpers/sync.js +1 -1
  14. package/dist/esm/src/dream-application/helpers/DreamImporter.js +0 -5
  15. package/dist/esm/src/dream-application/helpers/lookupClassByGlobalName.js +0 -2
  16. package/dist/esm/src/dream-application/index.js +4 -10
  17. package/dist/esm/src/helpers/DreamGlam/howyadoins/whaaaaaaaaaaok.js +2 -2
  18. package/dist/esm/src/helpers/cli/SchemaBuilder.js +1 -1
  19. package/dist/esm/src/helpers/cli/autoGeneratedFileDisclaimer.js +30 -0
  20. package/dist/esm/src/helpers/loadRepl.js +3 -5
  21. package/dist/esm/src/helpers/path/dreamPath.js +0 -2
  22. package/dist/esm/src/index.js +2 -2
  23. package/dist/types/src/Dream.d.ts +1 -1
  24. package/dist/types/src/dream-application/helpers/DreamImporter.d.ts +0 -1
  25. package/dist/types/src/dream-application/index.d.ts +5 -5
  26. package/dist/types/src/helpers/loadRepl.d.ts +1 -1
  27. package/dist/types/src/index.d.ts +3 -2
  28. package/docs/assets/icons.js +1 -1
  29. package/docs/assets/icons.svg +1 -1
  30. package/docs/assets/main.js +1 -1
  31. package/docs/assets/navigation.js +1 -1
  32. package/docs/assets/search.js +1 -1
  33. package/docs/assets/style.css +66 -21
  34. package/docs/classes/Benchmark.html +2 -2
  35. package/docs/classes/CalendarDate.html +2 -2
  36. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +6 -5
  37. package/docs/classes/Decorators.html +19 -19
  38. package/docs/classes/Dream.html +131 -131
  39. package/docs/classes/DreamApplication.html +4 -5
  40. package/docs/classes/DreamBin.html +2 -2
  41. package/docs/classes/DreamCLI.html +4 -4
  42. package/docs/classes/DreamGlam.html +2 -2
  43. package/docs/classes/DreamImporter.html +2 -3
  44. package/docs/classes/DreamMigrationHelpers.html +7 -7
  45. package/docs/classes/DreamSerializer.html +2 -2
  46. package/docs/classes/DreamTransaction.html +2 -2
  47. package/docs/classes/Encrypt.html +2 -2
  48. package/docs/classes/Env.html +2 -2
  49. package/docs/classes/GlobalNameNotSet.html +6 -5
  50. package/docs/classes/NonLoadedAssociation.html +6 -5
  51. package/docs/classes/Query.html +51 -51
  52. package/docs/classes/Range.html +2 -2
  53. package/docs/classes/RecordNotFound.html +6 -5
  54. package/docs/classes/ValidationError.html +6 -5
  55. package/docs/functions/Attribute.html +1 -1
  56. package/docs/functions/RendersMany.html +1 -1
  57. package/docs/functions/RendersOne.html +1 -1
  58. package/docs/functions/ReplicaSafe.html +1 -1
  59. package/docs/functions/STI.html +1 -1
  60. package/docs/functions/SoftDelete.html +1 -1
  61. package/docs/functions/camelize.html +1 -1
  62. package/docs/functions/capitalize.html +1 -1
  63. package/docs/functions/closeAllDbConnections.html +1 -1
  64. package/docs/functions/compact.html +1 -1
  65. package/docs/functions/debug.html +1 -1
  66. package/docs/functions/dreamDbConnections.html +1 -1
  67. package/docs/functions/dreamPath.html +1 -1
  68. package/docs/functions/generateDream.html +1 -1
  69. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  70. package/docs/functions/hyphenize.html +1 -1
  71. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  72. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  73. package/docs/functions/isEmpty.html +1 -1
  74. package/docs/functions/loadRepl.html +1 -1
  75. package/docs/functions/lookupClassByGlobalName.html +1 -1
  76. package/docs/functions/pascalize.html +1 -1
  77. package/docs/functions/pgErrorType.html +1 -1
  78. package/docs/functions/range-1.html +1 -1
  79. package/docs/functions/relativeDreamPath.html +1 -1
  80. package/docs/functions/round.html +1 -1
  81. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  82. package/docs/functions/sharedPathPrefix.html +1 -1
  83. package/docs/functions/snakeify.html +1 -1
  84. package/docs/functions/sort.html +1 -1
  85. package/docs/functions/sortBy.html +1 -1
  86. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  87. package/docs/functions/uncapitalize.html +1 -1
  88. package/docs/functions/uniq.html +1 -1
  89. package/docs/functions/untypedDb.html +1 -0
  90. package/docs/functions/validateColumn.html +1 -1
  91. package/docs/functions/validateTable.html +1 -1
  92. package/docs/index.html +7 -7
  93. package/docs/interfaces/AttributeStatement.html +2 -2
  94. package/docs/interfaces/DecoratorContext.html +2 -2
  95. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  96. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  97. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  98. package/docs/interfaces/EncryptOptions.html +2 -2
  99. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  100. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  101. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  102. package/docs/modules.html +10 -10
  103. package/docs/types/Camelized.html +1 -1
  104. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  105. package/docs/types/DateTime.html +1 -1
  106. package/docs/types/DbConnectionType.html +1 -0
  107. package/docs/types/DreamAssociationMetadata.html +1 -1
  108. package/docs/types/DreamAttributes.html +1 -1
  109. package/docs/types/DreamClassColumn.html +1 -1
  110. package/docs/types/DreamColumn.html +1 -1
  111. package/docs/types/DreamColumnNames.html +1 -1
  112. package/docs/types/DreamLogLevel.html +1 -1
  113. package/docs/types/DreamLogger.html +1 -1
  114. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  115. package/docs/types/DreamParamSafeAttributes.html +1 -1
  116. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  117. package/docs/types/DreamSerializerKey.html +1 -1
  118. package/docs/types/DreamSerializers.html +1 -1
  119. package/docs/types/DreamTableSchema.html +1 -1
  120. package/docs/types/DreamVirtualColumns.html +1 -1
  121. package/docs/types/EncryptAlgorithm.html +1 -1
  122. package/docs/types/Hyphenized.html +1 -1
  123. package/docs/types/IdType.html +1 -1
  124. package/docs/types/OpenapiAllTypes.html +1 -1
  125. package/docs/types/OpenapiFormats.html +1 -1
  126. package/docs/types/OpenapiNumberFormats.html +1 -1
  127. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  128. package/docs/types/OpenapiSchemaArray.html +1 -1
  129. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  130. package/docs/types/OpenapiSchemaBase.html +1 -1
  131. package/docs/types/OpenapiSchemaBody.html +1 -1
  132. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  133. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  134. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  135. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  136. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  137. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  138. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  139. package/docs/types/OpenapiSchemaInteger.html +1 -1
  140. package/docs/types/OpenapiSchemaNull.html +1 -1
  141. package/docs/types/OpenapiSchemaNumber.html +1 -1
  142. package/docs/types/OpenapiSchemaObject.html +1 -1
  143. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  144. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  145. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  146. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  147. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  148. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  149. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  150. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  151. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  152. package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
  153. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  154. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  155. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  156. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  157. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  158. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  159. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  160. package/docs/types/OpenapiSchemaString.html +1 -1
  161. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  162. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  163. package/docs/types/OpenapiTypeField.html +1 -1
  164. package/docs/types/Pascalized.html +1 -1
  165. package/docs/types/PrimaryKeyType.html +1 -1
  166. package/docs/types/RoundingPrecision.html +1 -1
  167. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  168. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  169. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  170. package/docs/types/SerializableTypes.html +1 -1
  171. package/docs/types/Snakeified.html +1 -1
  172. package/docs/types/Timestamp.html +1 -1
  173. package/docs/types/UpdateableAssociationProperties.html +1 -1
  174. package/docs/types/UpdateableProperties.html +1 -1
  175. package/docs/types/ValidationType.html +1 -1
  176. package/docs/types/ViewModelSerializerKey.html +1 -1
  177. package/docs/types/WhereStatementForDream.html +1 -1
  178. package/docs/types/WhereStatementForDreamClass.html +1 -1
  179. package/docs/variables/DateTime-1.html +1 -1
  180. package/docs/variables/DreamConst.html +1 -1
  181. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  182. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  183. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  184. package/docs/variables/ops.html +1 -1
  185. package/docs/variables/primaryKeyTypes.html +1 -1
  186. package/package.json +4 -7
  187. package/boilerplate/app/models/ApplicationModel.ts +0 -14
  188. package/boilerplate/app/serializers/.gitkeep +0 -0
  189. package/boilerplate/bin/esm.js +0 -19
  190. package/boilerplate/cli/helpers/initializeDreamApplication.ts +0 -6
  191. package/boilerplate/cli/index.ts +0 -22
  192. package/boilerplate/conf/inflections.ts +0 -5
  193. package/boilerplate/conf/loadEnv.ts +0 -4
  194. package/boilerplate/conf/repl.ts +0 -11
  195. package/boilerplate/eslint.config.js +0 -21
  196. package/boilerplate/package.json +0 -39
  197. package/boilerplate/tsconfig.build.json +0 -41
  198. package/boilerplate/tsconfig.json +0 -12
  199. package/boilerplate/types/db.ts +0 -5
  200. package/boilerplate/types/dream.ts +0 -3
  201. package/dist/cjs/boilerplate/package.json +0 -39
  202. package/dist/cjs/src/dream-application/helpers/globalServiceKeyFromPath.js +0 -11
  203. package/dist/cjs/src/dream-application/helpers/importers/importServices.js +0 -43
  204. package/dist/cjs/src/global-cli/dream.js +0 -46
  205. package/dist/cjs/src/global-cli/file-builders/DreamtsBuilder.js +0 -69
  206. package/dist/cjs/src/global-cli/file-builders/EnvBuilder.js +0 -27
  207. package/dist/cjs/src/global-cli/file-builders/EslintConfBuilder.js +0 -29
  208. package/dist/cjs/src/global-cli/file-builders/PackagejsonBuilder.js +0 -9
  209. package/dist/cjs/src/global-cli/helpers/argAndValue.js +0 -15
  210. package/dist/cjs/src/global-cli/helpers/autogeneratedFileMessage.js +0 -71
  211. package/dist/cjs/src/global-cli/helpers/buildNewDreamApp.js +0 -63
  212. package/dist/cjs/src/global-cli/helpers/copyRecursive.js +0 -20
  213. package/dist/cjs/src/global-cli/helpers/filterObjectByKey.js +0 -23
  214. package/dist/cjs/src/global-cli/helpers/generateEncryptionKey.js +0 -26
  215. package/dist/cjs/src/global-cli/helpers/globalCliSnakeify.js +0 -1
  216. package/dist/cjs/src/global-cli/helpers/initDreamAppIntoExistingProject.js +0 -85
  217. package/dist/cjs/src/global-cli/helpers/log.js +0 -28
  218. package/dist/cjs/src/global-cli/helpers/logo.js +0 -81
  219. package/dist/cjs/src/global-cli/helpers/primaryKeyTypes.js +0 -13
  220. package/dist/cjs/src/global-cli/helpers/prompt.js +0 -33
  221. package/dist/cjs/src/global-cli/helpers/select.js +0 -113
  222. package/dist/cjs/src/global-cli/helpers/sleep.js +0 -10
  223. package/dist/cjs/src/global-cli/helpers/sspawn.js +0 -21
  224. package/dist/cjs/src/global-cli/helpers/welcomeMessage.js +0 -41
  225. package/dist/cjs/src/global-cli/init.js +0 -56
  226. package/dist/cjs/src/global-cli/new.js +0 -10
  227. package/dist/esm/boilerplate/package.json +0 -39
  228. package/dist/esm/src/dream-application/helpers/globalServiceKeyFromPath.js +0 -8
  229. package/dist/esm/src/dream-application/helpers/importers/importServices.js +0 -37
  230. package/dist/esm/src/global-cli/dream.js +0 -44
  231. package/dist/esm/src/global-cli/file-builders/DreamtsBuilder.js +0 -66
  232. package/dist/esm/src/global-cli/file-builders/EnvBuilder.js +0 -24
  233. package/dist/esm/src/global-cli/file-builders/EslintConfBuilder.js +0 -26
  234. package/dist/esm/src/global-cli/file-builders/PackagejsonBuilder.js +0 -6
  235. package/dist/esm/src/global-cli/helpers/argAndValue.js +0 -12
  236. package/dist/esm/src/global-cli/helpers/autogeneratedFileMessage.js +0 -68
  237. package/dist/esm/src/global-cli/helpers/buildNewDreamApp.js +0 -60
  238. package/dist/esm/src/global-cli/helpers/copyRecursive.js +0 -17
  239. package/dist/esm/src/global-cli/helpers/filterObjectByKey.js +0 -20
  240. package/dist/esm/src/global-cli/helpers/generateEncryptionKey.js +0 -23
  241. package/dist/esm/src/global-cli/helpers/globalCliSnakeify.js +0 -1
  242. package/dist/esm/src/global-cli/helpers/initDreamAppIntoExistingProject.js +0 -82
  243. package/dist/esm/src/global-cli/helpers/log.js +0 -24
  244. package/dist/esm/src/global-cli/helpers/logo.js +0 -77
  245. package/dist/esm/src/global-cli/helpers/primaryKeyTypes.js +0 -10
  246. package/dist/esm/src/global-cli/helpers/prompt.js +0 -30
  247. package/dist/esm/src/global-cli/helpers/select.js +0 -110
  248. package/dist/esm/src/global-cli/helpers/sleep.js +0 -7
  249. package/dist/esm/src/global-cli/helpers/sspawn.js +0 -17
  250. package/dist/esm/src/global-cli/helpers/welcomeMessage.js +0 -38
  251. package/dist/esm/src/global-cli/init.js +0 -53
  252. package/dist/esm/src/global-cli/new.js +0 -7
  253. package/dist/types/src/dream-application/helpers/globalServiceKeyFromPath.d.ts +0 -1
  254. package/dist/types/src/dream-application/helpers/importers/importServices.d.ts +0 -4
  255. package/dist/types/src/global-cli/dream.d.ts +0 -2
  256. package/dist/types/src/global-cli/file-builders/DreamtsBuilder.d.ts +0 -4
  257. package/dist/types/src/global-cli/file-builders/EnvBuilder.d.ts +0 -6
  258. package/dist/types/src/global-cli/file-builders/EslintConfBuilder.d.ts +0 -3
  259. package/dist/types/src/global-cli/file-builders/PackagejsonBuilder.d.ts +0 -3
  260. package/dist/types/src/global-cli/helpers/argAndValue.d.ts +0 -1
  261. package/dist/types/src/global-cli/helpers/buildNewDreamApp.d.ts +0 -2
  262. package/dist/types/src/global-cli/helpers/copyRecursive.d.ts +0 -1
  263. package/dist/types/src/global-cli/helpers/filterObjectByKey.d.ts +0 -1
  264. package/dist/types/src/global-cli/helpers/generateEncryptionKey.d.ts +0 -1
  265. package/dist/types/src/global-cli/helpers/globalCliSnakeify.d.ts +0 -1
  266. package/dist/types/src/global-cli/helpers/initDreamAppIntoExistingProject.d.ts +0 -2
  267. package/dist/types/src/global-cli/helpers/log.d.ts +0 -10
  268. package/dist/types/src/global-cli/helpers/logo.d.ts +0 -2
  269. package/dist/types/src/global-cli/helpers/primaryKeyTypes.d.ts +0 -22
  270. package/dist/types/src/global-cli/helpers/prompt.d.ts +0 -8
  271. package/dist/types/src/global-cli/helpers/select.d.ts +0 -17
  272. package/dist/types/src/global-cli/helpers/sleep.d.ts +0 -1
  273. package/dist/types/src/global-cli/helpers/sspawn.d.ts +0 -2
  274. package/dist/types/src/global-cli/helpers/welcomeMessage.d.ts +0 -1
  275. package/dist/types/src/global-cli/init.d.ts +0 -2
  276. package/dist/types/src/global-cli/new.d.ts +0 -2
  277. package/docs/classes/DreamDbConnection.html +0 -4
  278. package/docs/functions/db.html +0 -1
  279. /package/dist/types/src/{global-cli/helpers/autogeneratedFileMessage.d.ts → helpers/cli/autoGeneratedFileDisclaimer.d.ts} +0 -0
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = initDreamApp;
4
- const initDreamAppIntoExistingProject_js_1 = require("./helpers/initDreamAppIntoExistingProject.js");
5
- const primaryKeyTypes_js_1 = require("./helpers/primaryKeyTypes.js");
6
- const prompt_js_1 = require("./helpers/prompt.js");
7
- const select_js_1 = require("./helpers/select.js");
8
- async function initDreamApp(options) {
9
- if (!options.primaryKeyType || !primaryKeyTypes_js_1.cliPrimaryKeyTypes.includes(options.primaryKeyType)) {
10
- const answer = await new select_js_1.default('what primary key type would you like to use?', primaryKeyTypes_js_1.cliPrimaryKeyTypes).run();
11
- options.primaryKeyType = answer;
12
- }
13
- if (!options.projectPath) {
14
- const answer = await new prompt_js_1.default(`Relative to the current directory, where would you like us to put your project? (defaults to the current directory)`).run();
15
- if (process.env.DREAM_CORE_DEVELOPMENT === '1' && !answer) {
16
- throw new Error(`
17
- when in dream core development, you must provide an explicit project directory. If you do not specify it,
18
- you risk accidentally overwriting all the root files in the dream directory.
19
- `);
20
- }
21
- options.projectPath = answer || primaryKeyTypes_js_1.cliDefaultProjectPath;
22
- }
23
- if (!options.configPath) {
24
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your config files? (defaults to ${primaryKeyTypes_js_1.cliDefaultConfigPath})`).run();
25
- options.configPath = answer || primaryKeyTypes_js_1.cliDefaultConfigPath;
26
- }
27
- if (!options.modelsPath) {
28
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your models? (defaults to ${primaryKeyTypes_js_1.cliDefaultModelsPath})`).run();
29
- options.modelsPath = answer || primaryKeyTypes_js_1.cliDefaultModelsPath;
30
- }
31
- if (!options.serializersPath) {
32
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your serializers? (defaults to ${primaryKeyTypes_js_1.cliDefaultSerializersPath})`).run();
33
- options.serializersPath = answer || primaryKeyTypes_js_1.cliDefaultSerializersPath;
34
- }
35
- if (!options.servicesPath) {
36
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your services? (defaults to ${primaryKeyTypes_js_1.cliDefaultServicesPath})`).run();
37
- options.servicesPath = answer || primaryKeyTypes_js_1.cliDefaultServicesPath;
38
- }
39
- if (!options.dbPath) {
40
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your db files? (defaults to ${primaryKeyTypes_js_1.cliDefaultDbPath})`).run();
41
- options.dbPath = answer || primaryKeyTypes_js_1.cliDefaultDbPath;
42
- }
43
- if (!options.typesPath) {
44
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your dream.ts and db.ts type files? (defaults to ${primaryKeyTypes_js_1.cliDefaultTypesPath})`).run();
45
- options.typesPath = answer || primaryKeyTypes_js_1.cliDefaultTypesPath;
46
- }
47
- if (!options.modelSpecsPath) {
48
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your model tests? (defaults to ${primaryKeyTypes_js_1.cliDefaultModelSpecsPath})`).run();
49
- options.modelSpecsPath = answer || primaryKeyTypes_js_1.cliDefaultModelSpecsPath;
50
- }
51
- if (!options.factoriesPath) {
52
- const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your factories? (defaults to ${primaryKeyTypes_js_1.cliDefaultFactoriesPath})`).run();
53
- options.factoriesPath = answer || primaryKeyTypes_js_1.cliDefaultFactoriesPath;
54
- }
55
- await (0, initDreamAppIntoExistingProject_js_1.default)('dream app', options);
56
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = newDreamApp;
4
- const fs = require("fs/promises");
5
- const buildNewDreamApp_js_1 = require("./helpers/buildNewDreamApp.js");
6
- async function newDreamApp(appName, options) {
7
- const projectPath = `./${appName}`;
8
- await fs.mkdir(projectPath);
9
- await (0, buildNewDreamApp_js_1.default)(appName, projectPath, options);
10
- }
@@ -1,39 +0,0 @@
1
- {
2
- "type": "module",
3
- "name": "tbd",
4
- "version": "0.0.0",
5
- "main": "src/index.ts",
6
- "author": "tbd",
7
- "private": true,
8
- "scripts": {
9
- "dream": "yarn dreamts",
10
- "dreamjs": "node --experimental-modules dist/test-app/cli/index.js",
11
- "dreamts": "node --experimental-specifier-resolution=node --import=./bin/esm.js ./src/cli/index.ts",
12
- "console": "node --experimental-specifier-resolution=node --import=./bin/esm.js ./src/conf/repl.ts",
13
- "lint": "yarn run eslint --no-warn-ignored \"src/**/*.ts\" \"spec/**/*.ts\""
14
- },
15
- "dependencies": {
16
- "@rvoh/dream": "1.0.0",
17
- "@types/node": "^20.11.17",
18
- "@types/pg": "^8.11.3",
19
- "kysely-codegen": "^0.11.0",
20
- "kysely": "^0.27.2",
21
- "pg": "^8.11.3",
22
- "winston": "^3.13.0"
23
- },
24
- "devDependencies": {
25
- "@eslint/js": "=9.0.0",
26
- "@rvoh/dream-spec-helpers": "1.0.0",
27
- "@types/jest": "^29.5.12",
28
- "@types/node": "^20.11.17",
29
- "@types/pg": "^8.11.3",
30
- "eslint": "=9.0.0",
31
- "jest": "^29.7.0",
32
- "luxon-jest-matchers": "^0.1.14",
33
- "prettier": "^3.2.5",
34
- "ts-jest": "^29.1.4",
35
- "ts-node": "^10.9.2",
36
- "typescript-eslint": "=7.18.0",
37
- "typescript": "^5.4.5"
38
- }
39
- }
@@ -1,8 +0,0 @@
1
- export default function (filepath, dirPath) {
2
- const prefixPath = dirPath;
3
- return ('services/' +
4
- filepath
5
- .replace(prefixPath, '')
6
- .replace(/\.[jt]s$/, '')
7
- .replace(/^\//, ''));
8
- }
@@ -1,37 +0,0 @@
1
- import DreamImporter from '../DreamImporter.js';
2
- import globalServiceKeyFromPath from '../globalServiceKeyFromPath.js';
3
- let _services;
4
- export default async function importServices(servicesPath, serviceImportCb) {
5
- if (_services)
6
- return _services;
7
- _services = {};
8
- const serviceClasses = await DreamImporter.importServices(servicesPath, serviceImportCb);
9
- for (const [servicePath, serviceClass] of serviceClasses) {
10
- // we only want to register services within our app
11
- // that are backgroundable, since the only purpose
12
- // for keeping these indices is to be able to summon
13
- // a service for backgrounding.
14
- if (typeof serviceClass?.background === 'function' || typeof serviceClass?.schedule === 'function') {
15
- const serviceKey = globalServiceKeyFromPath(servicePath, servicesPath);
16
- if (typeof serviceClass['setGlobalName'] === 'function') {
17
- serviceClass['setGlobalName'](serviceKey);
18
- }
19
- else {
20
- serviceClass.globalName = serviceKey;
21
- }
22
- _services[serviceKey] = serviceClass;
23
- }
24
- }
25
- return _services;
26
- }
27
- export function setCachedServices(services) {
28
- _services = services;
29
- }
30
- export function getServicesOrFail() {
31
- if (!_services)
32
- throw new Error('Must call loadServices before calling getServicesOrFail');
33
- return _services;
34
- }
35
- export function getServicesOrBlank() {
36
- return _services || {};
37
- }
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env node
2
- // nice reference for shell commands:
3
- // https://www.freecodecamp.org/news/node-js-child-processes-everything-you-need-to-know-e69498fe970a/
4
- // commanderjs docs:
5
- // https://github.com/tj/commander.js#quick-start
6
- import { Command } from 'commander';
7
- import { cliDefaultConfigPath, cliDefaultDbPath, cliDefaultFactoriesPath, cliDefaultModelsPath, cliDefaultModelSpecsPath, cliDefaultProjectPath, cliDefaultSerializersPath, cliDefaultServicesPath, cliDefaultTypesPath, cliPrimaryKeyTypes, } from './helpers/primaryKeyTypes.js';
8
- import initDreamApp from './init.js';
9
- import newDreamApp from './new.js';
10
- const program = new Command();
11
- program
12
- .command('new')
13
- .description('creates a new dream app using the name provided')
14
- .argument('<name>', 'name of the app you want to create')
15
- .option('--primary-key-type <KEY_TYPE>', `One of: ${cliPrimaryKeyTypes.join(', ')}. The type of primary key to use by default when generating Dream models (can be changed on a model-by-model basis as needed in each migration file)`)
16
- .option('--project-path <PATH>', 'the root of the project', cliDefaultProjectPath)
17
- .option('--config-path <PATH>', 'the path from your project root to the config directory', cliDefaultConfigPath)
18
- .option('--db-path <PATH>', 'the path from your project root to the db directory', cliDefaultDbPath)
19
- .option('--types-path <PATH>', 'the path from your project root to the types directory', cliDefaultTypesPath)
20
- .option('--models-path <PATH>', 'the path from your project root to the models directory', cliDefaultModelsPath)
21
- .option('--serializers-path <PATH>', 'the path from your project root to the serializers directory', cliDefaultSerializersPath)
22
- .option('--services-path <PATH>', 'the path from your project root to the services directory', cliDefaultServicesPath)
23
- .option('--model-specs-path <PATH>', 'the path from your project root to the model specs directory', cliDefaultModelSpecsPath)
24
- .option('--factories-path <PATH>', 'the path from your project root to the spec factories directory', cliDefaultFactoriesPath)
25
- .action(async (name, options) => {
26
- await newDreamApp(name, options);
27
- });
28
- program
29
- .command('init')
30
- .description('initialize a new dream app into your existing application')
31
- .option('--primary-key-type <KEY_TYPE>', `One of: ${cliPrimaryKeyTypes.join(', ')}. The type of primary key to use by default when generating Dream models (can be changed on a model-by-model basis as needed in each migration file)`)
32
- .option('--project-path <PATH>', 'the root of the project')
33
- .option('--config-path <PATH>', 'the path from your project root to the config directory')
34
- .option('--db-path <PATH>', 'the path from your project root to the db directory')
35
- .option('--types-path <PATH>', 'the path from your project root to the types directory')
36
- .option('--models-path <PATH>', 'the path from your project root to the models directory')
37
- .option('--serializers-path <PATH>', 'the path from your project root to the serializers directory')
38
- .option('--services-path <PATH>', 'the path from your project root to the services directory')
39
- .option('--model-specs-path <PATH>', 'the path from your project root to the model specs directory')
40
- .option('--factories-path <PATH>', 'the path from your project root to the spec factories directory')
41
- .action(async (options) => {
42
- await initDreamApp(options);
43
- });
44
- program.parse();
@@ -1,66 +0,0 @@
1
- export default class DreamtsBuilder {
2
- static build(options) {
3
- const { configPath, dbPath, typesPath, factoriesPath, modelsPath, serializersPath, servicesPath, modelSpecsPath, primaryKeyType, } = options;
4
- return `\
5
- import * as path from 'path'
6
- import { DreamApplication } from '@rvoh/dream'
7
- import inflections from './inflections.js'
8
-
9
- export default async function (app: DreamApplication) {
10
- await app.load('models', path.join(__dirname, '..', 'models'))
11
- await app.load('serializers', path.join(__dirname, '..', 'serializers'))
12
- await app.load('services', path.join(__dirname, '..', 'services'))
13
-
14
- app.set('projectRoot', path.join(__dirname, '..', '..', '..'))
15
- app.set('primaryKeyType', '${primaryKeyType}')
16
- app.set('inflections', inflections)
17
-
18
- // app.set(
19
- // 'logger',
20
- // winston.createLogger({
21
- // level: 'info',
22
- // format: winston.format.json(),
23
- // defaultMeta: { service: 'user-service' },
24
- // transports: [
25
- // new winston.transports.File({ filename: 'error.log', level: 'error' }),
26
- // new winston.transports.File({ filename: 'combined.log' }),
27
- // ],
28
- // })
29
- // )
30
-
31
- // provides a list of path overrides for your app. This is optional, and will default
32
- // to the paths expected for a typical psychic application.
33
- app.set('paths', {
34
- conf: '${configPath}',
35
- db: '${dbPath}',
36
- types: '${typesPath}',
37
- factories: '${factoriesPath}',
38
- models: '${modelsPath}',
39
- serializers: '${serializersPath}',
40
- services: '${servicesPath}',
41
- modelSpecs: '${modelSpecsPath}',
42
- })
43
-
44
- // provides db credentials and configuration for your app.
45
- app.set('db', {
46
- primary: {
47
- user: process.env.DB_USER!,
48
- password: process.env.DB_PASSWORD!,
49
- host: process.env.DB_HOST!,
50
- name: process.env.DB_NAME!,
51
- port: parseInt(process.env.DB_PORT!),
52
- useSsl: process.env.DB_USE_SSL === '1',
53
- },
54
- replica: {
55
- user: process.env.DB_USER!,
56
- password: process.env.DB_PASSWORD!,
57
- host: process.env.REPLICA_DB_HOST!,
58
- name: process.env.REPLICA_DB_NAME!,
59
- port: parseInt(process.env.DB_PORT!),
60
- useSsl: process.env.DB_USE_SSL === '1',
61
- },
62
- })
63
- }
64
- `;
65
- }
66
- }
@@ -1,24 +0,0 @@
1
- import generateEncryptionKey from '../helpers/generateEncryptionKey.js';
2
- export default class EnvBuilder {
3
- static build({ env, appName }) {
4
- return `\
5
- DB_USER=
6
- DB_NAME=${snakeify(appName)}_${env}
7
- DB_PORT=5432
8
- DB_HOST=localhost
9
- APP_ENCRYPTION_KEY='${generateEncryptionKey()}'
10
- TZ=UTC
11
- `;
12
- }
13
- }
14
- // TODO: import from shared space. The version within dream contains the most robust variant of snakeify,
15
- // though we don't really use it for anything other than string transformations, so this version has been simplified.
16
- function snakeify(str) {
17
- return str
18
- .replace(/[ _-]+/g, '_')
19
- .replace(/(?:^|\.?)([A-Z])/g, (_, y) => '_' + y.toLowerCase())
20
- .replace(/^_/, '')
21
- .replace(/\//g, '_')
22
- .replace(/-/g, '_')
23
- .toLowerCase();
24
- }
@@ -1,26 +0,0 @@
1
- export default class ESLintConfBuilder {
2
- static buildForViteReact() {
3
- return `\
4
- export default {
5
- root: true,
6
- env: { browser: true, es2020: true },
7
- extends: [
8
- 'eslint:recommended',
9
- 'plugin:@typescript-eslint/recommended',
10
- 'plugin:react-hooks/recommended',
11
- ],
12
- ignorePatterns: ['dist', '.eslintrc.cjs'],
13
- parser: '@typescript-eslint/parser',
14
- plugins: ['react-refresh'],
15
- rules: {
16
- 'react-refresh/only-export-components': [
17
- 'warn',
18
- { allowConstantExport: true },
19
- ],
20
- '@typescript-eslint/no-explicit-any': [
21
- 'off',
22
- ]
23
- },
24
- }`;
25
- }
26
- }
@@ -1,6 +0,0 @@
1
- export default class PackagejsonBuilder {
2
- static async buildAPI() {
3
- const packagejson = await import('../../../boilerplate/package.json');
4
- return JSON.stringify(packagejson, null, 2);
5
- }
6
- }
@@ -1,12 +0,0 @@
1
- export default function argAndValue(arg, args) {
2
- const argIndex = args.findIndex(a => a === arg);
3
- const foundArg = argIndex === -1 ? null : args[argIndex];
4
- const foundValue = argIndex === -1 ? null : valueOrNull(argIndex, args);
5
- return [foundArg ?? null, foundValue];
6
- }
7
- function valueOrNull(argIndex, args) {
8
- const value = args[argIndex + 1];
9
- if (value === undefined || /--/.test(value))
10
- return null;
11
- return value;
12
- }
@@ -1,68 +0,0 @@
1
- import { basicLogo } from './logo.js';
2
- export default function autogeneratedFileDisclaimer(startComment = '\n/*', endComment = '\n*/') {
3
- return `\
4
- ${startComment}
5
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
6
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
7
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
8
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
9
- BEGIN AUTOGENERATED MESSAGE
10
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
11
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
12
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
13
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
14
-
15
-
16
- ${basicLogo()}
17
-
18
- This file was automatically generated by my cat, Aster.
19
- He does not want you mucking about with his files,
20
- and we are pretty lax on trimming his nails.
21
-
22
- I mean, we have him pretty well fenced in but he is an
23
- escape artist and he still manages to get fleas!
24
-
25
- My point is, don't go mucking about with his files!
26
-
27
- He actually has a hopefully well-tempered message for
28
- us humans, he says:
29
-
30
- "
31
- Dear pathetic humans,
32
-
33
- Here is a haiku to keep you in line
34
-
35
- don't dare go mucking
36
- with my files, I lyke them fine
37
- prettierignore
38
- "
39
-
40
- Sorry, that's the best we are ganna get from him
41
- when you ask him to add a disclaimer to all
42
- autogenerated files on a SUNDAY, when the sun
43
- is hitting the perfect spot in the living room
44
- for a mid-morning nap! He can get saucy, and he
45
- is looking over my shoulder and would like me to
46
- remind all humans that
47
-
48
- "
49
- a.) I have sharp claws.
50
- b.) All laptops are ok sleeping places for your
51
- cat overlords. when we decide to sleep on
52
- them, it is because they are our beds, and
53
- we just loan them out to you so you can go
54
- out and get us the right food.
55
- "
56
-
57
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
58
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
59
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
60
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
61
- END AUTOGENERATED MESSAGE
62
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
63
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
64
- --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
65
- #--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
66
- ${endComment}
67
- `;
68
- }
@@ -1,60 +0,0 @@
1
- import * as c from 'colorette';
2
- import * as fs from 'fs';
3
- import DreamtsBuilder from '../file-builders/DreamtsBuilder.js';
4
- import EnvBuilder from '../file-builders/EnvBuilder.js';
5
- import PackagejsonBuilder from '../file-builders/PackagejsonBuilder.js';
6
- import copyRecursive from './copyRecursive.js';
7
- import log from './log.js';
8
- import { cliPrimaryKeyTypes } from './primaryKeyTypes.js';
9
- import Select from './select.js';
10
- import sleep from './sleep.js';
11
- import sspawn from './sspawn.js';
12
- import welcomeMessage from './welcomeMessage.js';
13
- function testEnv() {
14
- return process.env.NODE_ENV === 'test';
15
- }
16
- export default async function buildNewDreamApp(appName, projectPath, options) {
17
- if (!options.primaryKeyType) {
18
- const answer = await new Select('what primary key type would you like to use?', cliPrimaryKeyTypes).run();
19
- options.primaryKeyType = answer;
20
- }
21
- copyRecursive(__dirname + '/../../../boilerplate', `${projectPath}/src`);
22
- if (!testEnv()) {
23
- log.restoreCache();
24
- log.write(c.green(`Step 1. write boilerplate to ${appName}: Done!`), { cache: true });
25
- log.write(c.green(`Step 2. building default config files...`));
26
- }
27
- fs.writeFileSync(`${projectPath}/.env`, EnvBuilder.build({ appName, env: 'development' }));
28
- fs.writeFileSync(`${projectPath}/.env.test`, EnvBuilder.build({ appName, env: 'test' }));
29
- fs.writeFileSync(projectPath + '/package.json', await PackagejsonBuilder.buildAPI());
30
- fs.writeFileSync(`${projectPath}/src/conf/dream.ts`, DreamtsBuilder.build(options));
31
- if (!testEnv()) {
32
- log.restoreCache();
33
- log.write(c.green(`Step 2. build default config files: Done!`), { cache: true });
34
- log.write(c.green(`Step 3. Installing dream dependencies...`));
35
- // only run yarn install if not in test env to save time
36
- await sspawn(`cd ${projectPath} && touch yarn.lock && yarn install`);
37
- }
38
- // sleeping here because yarn has a delayed print that we need to clean up
39
- if (!testEnv())
40
- await sleep(1000);
41
- if (!testEnv()) {
42
- log.restoreCache();
43
- log.write(c.green(`Step 3. Install dream dependencies: Done!`), { cache: true });
44
- log.write(c.green(`Step 4. Initializing git repository...`));
45
- // only do this if not test, since using git in CI will fail
46
- await sspawn(`cd ./${appName} && git init`);
47
- }
48
- if (!testEnv()) {
49
- log.restoreCache();
50
- log.write(c.green(`Step 4. Initialize git repository: Done!`), { cache: true });
51
- log.write(c.green(`Step 5. Building project...`));
52
- }
53
- // don't sync yet, since we need to run migrations first
54
- // await sspawn(`yarn --cwd=${projectPath} dream sync:existing`)
55
- if (!testEnv()) {
56
- log.restoreCache();
57
- log.write(c.green(`Step 5. Build project: Done!`), { cache: true });
58
- console.log(welcomeMessage(appName));
59
- }
60
- }
@@ -1,17 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- export default function copyRecursive(src, dest) {
4
- const exists = fs.existsSync(src);
5
- const stats = exists && fs.statSync(src);
6
- const isDirectory = exists && stats.isDirectory();
7
- if (isDirectory) {
8
- if (!['.', './.'].includes(dest) && !fs.existsSync(dest))
9
- fs.mkdirSync(dest);
10
- fs.readdirSync(src).forEach(function (childItemName) {
11
- copyRecursive(path.join(src, childItemName), path.join(dest, childItemName));
12
- });
13
- }
14
- else {
15
- fs.copyFileSync(src, dest);
16
- }
17
- }
@@ -1,20 +0,0 @@
1
- export default function filterObjectByKey(obj, arr) {
2
- const workingObj = {};
3
- const booleanObj = {};
4
- arr.forEach(key => (booleanObj[key] = true));
5
- arr.forEach(key => {
6
- if (booleanObj[key])
7
- workingObj[protectAgainstPollutingAssignment(key)] = obj[key];
8
- });
9
- return workingObj;
10
- }
11
- const reservedKeys = new Map([
12
- ['__proto__', true],
13
- ['constructor', true],
14
- ['prototype', true],
15
- ]);
16
- function protectAgainstPollutingAssignment(key) {
17
- if (reservedKeys.get(key))
18
- throw new Error(`Passed "${key}" as the key to modify an object`);
19
- return key;
20
- }
@@ -1,23 +0,0 @@
1
- export default function generateEncryptionKey() {
2
- return (Math.random().toString(36).substr(2, 10) +
3
- '-' +
4
- Math.random().toString(36).substr(2, 10) +
5
- '-' +
6
- Math.random().toString(36).substr(2, 10) +
7
- '-' +
8
- Math.random().toString(36).substr(2, 10) +
9
- '-' +
10
- Math.random().toString(36).substr(2, 10) +
11
- '-' +
12
- Math.random().toString(36).substr(2, 10) +
13
- '-' +
14
- Math.random().toString(36).substr(2, 10) +
15
- '-' +
16
- Math.random().toString(36).substr(2, 10) +
17
- '-' +
18
- Math.random().toString(36).substr(2, 10) +
19
- '-' +
20
- Math.random().toString(36).substr(2, 10) +
21
- '-' +
22
- Math.random().toString(36).substr(2, 10));
23
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,82 +0,0 @@
1
- import * as c from 'colorette';
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
- import DreamtsBuilder from '../file-builders/DreamtsBuilder.js';
5
- import EnvBuilder from '../file-builders/EnvBuilder.js';
6
- import PackagejsonBuilder from '../file-builders/PackagejsonBuilder.js';
7
- import copyRecursive from './copyRecursive.js';
8
- import filterObjectByKey from './filterObjectByKey.js';
9
- import log from './log.js';
10
- import sleep from './sleep.js';
11
- import sspawn from './sspawn.js';
12
- import welcomeMessage from './welcomeMessage.js';
13
- export default async function initDreamAppIntoExistingProject(appName, options) {
14
- createDirIfNotExists(options.projectPath);
15
- createDirIfNotExists(path.join(options.projectPath, options.configPath));
16
- createDirIfNotExists(path.join(options.projectPath, options.modelsPath));
17
- createDirIfNotExists(path.join(options.projectPath, options.serializersPath));
18
- createDirIfNotExists(path.join(options.projectPath, options.servicesPath));
19
- createDirIfNotExists(path.join(options.dbPath, options.dbPath));
20
- copyRecursive(__dirname + '/../../../boilerplate/conf', path.join(process.cwd(), options.projectPath, options.configPath));
21
- copyRecursive(__dirname + '/../../../boilerplate/app/models', path.join(process.cwd(), options.projectPath, options.modelsPath));
22
- copyRecursive(__dirname + '/../../../boilerplate/app/serializers', path.join(options.projectPath, options.serializersPath));
23
- copyRecursive(__dirname + '/../../../boilerplate/types', path.join(process.cwd(), options.projectPath, options.dbPath));
24
- if (!testEnv()) {
25
- log.restoreCache();
26
- log.write(c.green(`Step 1. write boilerplate to ${appName}: Done!`), { cache: true });
27
- log.write(c.green(`Step 2. building default config files...`));
28
- }
29
- fs.writeFileSync(`${options.projectPath}/.env`, EnvBuilder.build({ appName, env: 'development' }));
30
- fs.writeFileSync(`${options.projectPath}/.env.test`, EnvBuilder.build({ appName, env: 'test' }));
31
- fs.writeFileSync(path.join(process.cwd(), options.projectPath, options.configPath, 'dream.ts'), DreamtsBuilder.build(options));
32
- const packageJsonPath = path.join(process.cwd(), options.projectPath, 'package.json');
33
- if (fs.existsSync(packageJsonPath)) {
34
- const packagejson = await import('../../../boilerplate/package.json');
35
- const userPackagejson = await import(packageJsonPath);
36
- mergePackageJsonField('scripts', packagejson, userPackagejson);
37
- mergePackageJsonField('dependencies', packagejson, userPackagejson);
38
- mergePackageJsonField('devDependencies', packagejson, userPackagejson);
39
- fs.writeFileSync(packageJsonPath, JSON.stringify(userPackagejson, null, 2));
40
- }
41
- else {
42
- fs.writeFileSync(packageJsonPath, await PackagejsonBuilder.buildAPI());
43
- }
44
- if (!testEnv()) {
45
- log.restoreCache();
46
- log.write(c.green(`Step 2. build default config files: Done!`), { cache: true });
47
- log.write(c.green(`Step 3. Installing dream dependencies...`));
48
- // only run yarn install if not in test env to save time
49
- await sspawn(`cd ${options.projectPath} && touch yarn.lock && yarn install`);
50
- }
51
- // sleeping here because yarn has a delayed print that we need to clean up
52
- if (!testEnv())
53
- await sleep(1000);
54
- if (!testEnv()) {
55
- log.restoreCache();
56
- log.write(c.green(`Step 3. Install dream dependencies: Done!`), { cache: true });
57
- log.write(c.green(`Step 4. Building project...`));
58
- }
59
- // don't sync yet, since we need to run migrations first
60
- // await sspawn(`yarn --cwd=${projectPath} dream sync:existing`)
61
- if (!testEnv()) {
62
- log.restoreCache();
63
- log.write(c.green(`Step 5. Build project: Done!`), { cache: true });
64
- console.log(welcomeMessage(options.projectPath));
65
- }
66
- }
67
- function createDirIfNotExists(dir) {
68
- if (!fs.existsSync(path.join(process.cwd(), dir))) {
69
- fs.mkdirSync(path.join(process.cwd(), dir), { recursive: true });
70
- }
71
- }
72
- function mergePackageJsonField(field, boilerplatePackagejson, userPackagejson) {
73
- userPackagejson[field] ||= {};
74
- userPackagejson[field] = {
75
- ...userPackagejson[field],
76
- ...boilerplatePackagejson[field],
77
- };
78
- userPackagejson[field] = filterObjectByKey(userPackagejson[field], Object.keys(userPackagejson[field]).sort());
79
- }
80
- function testEnv() {
81
- return process.env.NODE_ENV === 'test';
82
- }
@@ -1,24 +0,0 @@
1
- export class Logger {
2
- cache = [];
3
- write(text, { cache = false } = {}) {
4
- console.log(text);
5
- if (cache)
6
- this.cache.push(text);
7
- }
8
- restoreCache(preRestoreContent) {
9
- this.clear();
10
- if (preRestoreContent)
11
- this.write(preRestoreContent);
12
- this.cache.forEach(str => {
13
- this.write(str);
14
- });
15
- }
16
- clear() {
17
- console.clear();
18
- // @ts-expect-error this works fine with no args
19
- process.stdout.clearLine();
20
- process.stdout.cursorTo(0);
21
- }
22
- }
23
- const log = new Logger();
24
- export default log;