@rvoh/dream 0.32.4 → 0.33.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 (267) 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/esm/src/Dream.js +1 -1
  12. package/dist/esm/src/bin/helpers/sync.js +1 -1
  13. package/dist/esm/src/dream-application/helpers/DreamImporter.js +0 -5
  14. package/dist/esm/src/dream-application/helpers/lookupClassByGlobalName.js +0 -2
  15. package/dist/esm/src/dream-application/index.js +4 -10
  16. package/dist/esm/src/helpers/DreamGlam/howyadoins/whaaaaaaaaaaok.js +2 -2
  17. package/dist/esm/src/helpers/cli/SchemaBuilder.js +1 -1
  18. package/dist/esm/src/helpers/cli/autoGeneratedFileDisclaimer.js +30 -0
  19. package/dist/esm/src/helpers/loadRepl.js +3 -5
  20. package/dist/esm/src/helpers/path/dreamPath.js +0 -2
  21. package/dist/types/src/Dream.d.ts +1 -1
  22. package/dist/types/src/dream-application/helpers/DreamImporter.d.ts +0 -1
  23. package/dist/types/src/dream-application/index.d.ts +5 -5
  24. package/dist/types/src/helpers/loadRepl.d.ts +1 -1
  25. package/docs/assets/search.js +1 -1
  26. package/docs/classes/Benchmark.html +2 -2
  27. package/docs/classes/CalendarDate.html +2 -2
  28. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  29. package/docs/classes/Decorators.html +19 -19
  30. package/docs/classes/Dream.html +126 -126
  31. package/docs/classes/DreamApplication.html +4 -5
  32. package/docs/classes/DreamBin.html +2 -2
  33. package/docs/classes/DreamCLI.html +4 -4
  34. package/docs/classes/DreamDbConnection.html +2 -2
  35. package/docs/classes/DreamGlam.html +2 -2
  36. package/docs/classes/DreamImporter.html +2 -3
  37. package/docs/classes/DreamMigrationHelpers.html +7 -7
  38. package/docs/classes/DreamSerializer.html +2 -2
  39. package/docs/classes/DreamTransaction.html +2 -2
  40. package/docs/classes/Encrypt.html +2 -2
  41. package/docs/classes/Env.html +2 -2
  42. package/docs/classes/GlobalNameNotSet.html +3 -3
  43. package/docs/classes/NonLoadedAssociation.html +3 -3
  44. package/docs/classes/Query.html +50 -50
  45. package/docs/classes/Range.html +2 -2
  46. package/docs/classes/RecordNotFound.html +3 -3
  47. package/docs/classes/ValidationError.html +3 -3
  48. package/docs/functions/Attribute.html +1 -1
  49. package/docs/functions/RendersMany.html +1 -1
  50. package/docs/functions/RendersOne.html +1 -1
  51. package/docs/functions/ReplicaSafe.html +1 -1
  52. package/docs/functions/STI.html +1 -1
  53. package/docs/functions/SoftDelete.html +1 -1
  54. package/docs/functions/camelize.html +1 -1
  55. package/docs/functions/capitalize.html +1 -1
  56. package/docs/functions/closeAllDbConnections.html +1 -1
  57. package/docs/functions/compact.html +1 -1
  58. package/docs/functions/db.html +1 -1
  59. package/docs/functions/debug.html +1 -1
  60. package/docs/functions/dreamDbConnections.html +1 -1
  61. package/docs/functions/dreamPath.html +1 -1
  62. package/docs/functions/generateDream.html +1 -1
  63. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  64. package/docs/functions/hyphenize.html +1 -1
  65. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  66. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  67. package/docs/functions/isEmpty.html +1 -1
  68. package/docs/functions/loadRepl.html +1 -1
  69. package/docs/functions/lookupClassByGlobalName.html +1 -1
  70. package/docs/functions/pascalize.html +1 -1
  71. package/docs/functions/pgErrorType.html +1 -1
  72. package/docs/functions/range-1.html +1 -1
  73. package/docs/functions/relativeDreamPath.html +1 -1
  74. package/docs/functions/round.html +1 -1
  75. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  76. package/docs/functions/sharedPathPrefix.html +1 -1
  77. package/docs/functions/snakeify.html +1 -1
  78. package/docs/functions/sort.html +1 -1
  79. package/docs/functions/sortBy.html +1 -1
  80. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  81. package/docs/functions/uncapitalize.html +1 -1
  82. package/docs/functions/uniq.html +1 -1
  83. package/docs/functions/validateColumn.html +1 -1
  84. package/docs/functions/validateTable.html +1 -1
  85. package/docs/interfaces/AttributeStatement.html +2 -2
  86. package/docs/interfaces/DecoratorContext.html +2 -2
  87. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  88. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  89. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  90. package/docs/interfaces/EncryptOptions.html +2 -2
  91. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  92. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  93. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  94. package/docs/types/Camelized.html +1 -1
  95. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  96. package/docs/types/DateTime.html +1 -1
  97. package/docs/types/DreamAssociationMetadata.html +1 -1
  98. package/docs/types/DreamAttributes.html +1 -1
  99. package/docs/types/DreamClassColumn.html +1 -1
  100. package/docs/types/DreamColumn.html +1 -1
  101. package/docs/types/DreamColumnNames.html +1 -1
  102. package/docs/types/DreamLogLevel.html +1 -1
  103. package/docs/types/DreamLogger.html +1 -1
  104. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  105. package/docs/types/DreamParamSafeAttributes.html +1 -1
  106. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  107. package/docs/types/DreamSerializerKey.html +1 -1
  108. package/docs/types/DreamSerializers.html +1 -1
  109. package/docs/types/DreamTableSchema.html +1 -1
  110. package/docs/types/DreamVirtualColumns.html +1 -1
  111. package/docs/types/EncryptAlgorithm.html +1 -1
  112. package/docs/types/Hyphenized.html +1 -1
  113. package/docs/types/IdType.html +1 -1
  114. package/docs/types/OpenapiAllTypes.html +1 -1
  115. package/docs/types/OpenapiFormats.html +1 -1
  116. package/docs/types/OpenapiNumberFormats.html +1 -1
  117. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  118. package/docs/types/OpenapiSchemaArray.html +1 -1
  119. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  120. package/docs/types/OpenapiSchemaBase.html +1 -1
  121. package/docs/types/OpenapiSchemaBody.html +1 -1
  122. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  123. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  124. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  125. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  126. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  127. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  128. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  129. package/docs/types/OpenapiSchemaInteger.html +1 -1
  130. package/docs/types/OpenapiSchemaNull.html +1 -1
  131. package/docs/types/OpenapiSchemaNumber.html +1 -1
  132. package/docs/types/OpenapiSchemaObject.html +1 -1
  133. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  134. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  135. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  136. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  137. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  138. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  139. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  140. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  141. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  142. package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
  143. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  144. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  145. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  146. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  147. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  148. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  149. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  150. package/docs/types/OpenapiSchemaString.html +1 -1
  151. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  152. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  153. package/docs/types/OpenapiTypeField.html +1 -1
  154. package/docs/types/Pascalized.html +1 -1
  155. package/docs/types/PrimaryKeyType.html +1 -1
  156. package/docs/types/RoundingPrecision.html +1 -1
  157. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  158. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  159. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  160. package/docs/types/SerializableTypes.html +1 -1
  161. package/docs/types/Snakeified.html +1 -1
  162. package/docs/types/Timestamp.html +1 -1
  163. package/docs/types/UpdateableAssociationProperties.html +1 -1
  164. package/docs/types/UpdateableProperties.html +1 -1
  165. package/docs/types/ValidationType.html +1 -1
  166. package/docs/types/ViewModelSerializerKey.html +1 -1
  167. package/docs/types/WhereStatementForDream.html +1 -1
  168. package/docs/types/WhereStatementForDreamClass.html +1 -1
  169. package/docs/variables/DateTime-1.html +1 -1
  170. package/docs/variables/DreamConst.html +1 -1
  171. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  172. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  173. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  174. package/docs/variables/ops.html +1 -1
  175. package/docs/variables/primaryKeyTypes.html +1 -1
  176. package/package.json +2 -5
  177. package/boilerplate/app/models/ApplicationModel.ts +0 -14
  178. package/boilerplate/app/serializers/.gitkeep +0 -0
  179. package/boilerplate/bin/esm.js +0 -19
  180. package/boilerplate/cli/helpers/initializeDreamApplication.ts +0 -6
  181. package/boilerplate/cli/index.ts +0 -22
  182. package/boilerplate/conf/inflections.ts +0 -5
  183. package/boilerplate/conf/loadEnv.ts +0 -4
  184. package/boilerplate/conf/repl.ts +0 -11
  185. package/boilerplate/eslint.config.js +0 -21
  186. package/boilerplate/package.json +0 -39
  187. package/boilerplate/tsconfig.build.json +0 -41
  188. package/boilerplate/tsconfig.json +0 -12
  189. package/boilerplate/types/db.ts +0 -5
  190. package/boilerplate/types/dream.ts +0 -3
  191. package/dist/cjs/boilerplate/package.json +0 -39
  192. package/dist/cjs/src/dream-application/helpers/globalServiceKeyFromPath.js +0 -11
  193. package/dist/cjs/src/dream-application/helpers/importers/importServices.js +0 -43
  194. package/dist/cjs/src/global-cli/dream.js +0 -46
  195. package/dist/cjs/src/global-cli/file-builders/DreamtsBuilder.js +0 -69
  196. package/dist/cjs/src/global-cli/file-builders/EnvBuilder.js +0 -27
  197. package/dist/cjs/src/global-cli/file-builders/EslintConfBuilder.js +0 -29
  198. package/dist/cjs/src/global-cli/file-builders/PackagejsonBuilder.js +0 -9
  199. package/dist/cjs/src/global-cli/helpers/argAndValue.js +0 -15
  200. package/dist/cjs/src/global-cli/helpers/autogeneratedFileMessage.js +0 -71
  201. package/dist/cjs/src/global-cli/helpers/buildNewDreamApp.js +0 -63
  202. package/dist/cjs/src/global-cli/helpers/copyRecursive.js +0 -20
  203. package/dist/cjs/src/global-cli/helpers/filterObjectByKey.js +0 -23
  204. package/dist/cjs/src/global-cli/helpers/generateEncryptionKey.js +0 -26
  205. package/dist/cjs/src/global-cli/helpers/globalCliSnakeify.js +0 -1
  206. package/dist/cjs/src/global-cli/helpers/initDreamAppIntoExistingProject.js +0 -85
  207. package/dist/cjs/src/global-cli/helpers/log.js +0 -28
  208. package/dist/cjs/src/global-cli/helpers/logo.js +0 -81
  209. package/dist/cjs/src/global-cli/helpers/primaryKeyTypes.js +0 -13
  210. package/dist/cjs/src/global-cli/helpers/prompt.js +0 -33
  211. package/dist/cjs/src/global-cli/helpers/select.js +0 -113
  212. package/dist/cjs/src/global-cli/helpers/sleep.js +0 -10
  213. package/dist/cjs/src/global-cli/helpers/sspawn.js +0 -21
  214. package/dist/cjs/src/global-cli/helpers/welcomeMessage.js +0 -41
  215. package/dist/cjs/src/global-cli/init.js +0 -56
  216. package/dist/cjs/src/global-cli/new.js +0 -10
  217. package/dist/esm/boilerplate/package.json +0 -39
  218. package/dist/esm/src/dream-application/helpers/globalServiceKeyFromPath.js +0 -8
  219. package/dist/esm/src/dream-application/helpers/importers/importServices.js +0 -37
  220. package/dist/esm/src/global-cli/dream.js +0 -44
  221. package/dist/esm/src/global-cli/file-builders/DreamtsBuilder.js +0 -66
  222. package/dist/esm/src/global-cli/file-builders/EnvBuilder.js +0 -24
  223. package/dist/esm/src/global-cli/file-builders/EslintConfBuilder.js +0 -26
  224. package/dist/esm/src/global-cli/file-builders/PackagejsonBuilder.js +0 -6
  225. package/dist/esm/src/global-cli/helpers/argAndValue.js +0 -12
  226. package/dist/esm/src/global-cli/helpers/autogeneratedFileMessage.js +0 -68
  227. package/dist/esm/src/global-cli/helpers/buildNewDreamApp.js +0 -60
  228. package/dist/esm/src/global-cli/helpers/copyRecursive.js +0 -17
  229. package/dist/esm/src/global-cli/helpers/filterObjectByKey.js +0 -20
  230. package/dist/esm/src/global-cli/helpers/generateEncryptionKey.js +0 -23
  231. package/dist/esm/src/global-cli/helpers/globalCliSnakeify.js +0 -1
  232. package/dist/esm/src/global-cli/helpers/initDreamAppIntoExistingProject.js +0 -82
  233. package/dist/esm/src/global-cli/helpers/log.js +0 -24
  234. package/dist/esm/src/global-cli/helpers/logo.js +0 -77
  235. package/dist/esm/src/global-cli/helpers/primaryKeyTypes.js +0 -10
  236. package/dist/esm/src/global-cli/helpers/prompt.js +0 -30
  237. package/dist/esm/src/global-cli/helpers/select.js +0 -110
  238. package/dist/esm/src/global-cli/helpers/sleep.js +0 -7
  239. package/dist/esm/src/global-cli/helpers/sspawn.js +0 -17
  240. package/dist/esm/src/global-cli/helpers/welcomeMessage.js +0 -38
  241. package/dist/esm/src/global-cli/init.js +0 -53
  242. package/dist/esm/src/global-cli/new.js +0 -7
  243. package/dist/types/src/dream-application/helpers/globalServiceKeyFromPath.d.ts +0 -1
  244. package/dist/types/src/dream-application/helpers/importers/importServices.d.ts +0 -4
  245. package/dist/types/src/global-cli/dream.d.ts +0 -2
  246. package/dist/types/src/global-cli/file-builders/DreamtsBuilder.d.ts +0 -4
  247. package/dist/types/src/global-cli/file-builders/EnvBuilder.d.ts +0 -6
  248. package/dist/types/src/global-cli/file-builders/EslintConfBuilder.d.ts +0 -3
  249. package/dist/types/src/global-cli/file-builders/PackagejsonBuilder.d.ts +0 -3
  250. package/dist/types/src/global-cli/helpers/argAndValue.d.ts +0 -1
  251. package/dist/types/src/global-cli/helpers/buildNewDreamApp.d.ts +0 -2
  252. package/dist/types/src/global-cli/helpers/copyRecursive.d.ts +0 -1
  253. package/dist/types/src/global-cli/helpers/filterObjectByKey.d.ts +0 -1
  254. package/dist/types/src/global-cli/helpers/generateEncryptionKey.d.ts +0 -1
  255. package/dist/types/src/global-cli/helpers/globalCliSnakeify.d.ts +0 -1
  256. package/dist/types/src/global-cli/helpers/initDreamAppIntoExistingProject.d.ts +0 -2
  257. package/dist/types/src/global-cli/helpers/log.d.ts +0 -10
  258. package/dist/types/src/global-cli/helpers/logo.d.ts +0 -2
  259. package/dist/types/src/global-cli/helpers/primaryKeyTypes.d.ts +0 -22
  260. package/dist/types/src/global-cli/helpers/prompt.d.ts +0 -8
  261. package/dist/types/src/global-cli/helpers/select.d.ts +0 -17
  262. package/dist/types/src/global-cli/helpers/sleep.d.ts +0 -1
  263. package/dist/types/src/global-cli/helpers/sspawn.d.ts +0 -2
  264. package/dist/types/src/global-cli/helpers/welcomeMessage.d.ts +0 -1
  265. package/dist/types/src/global-cli/init.d.ts +0 -2
  266. package/dist/types/src/global-cli/new.d.ts +0 -2
  267. /package/dist/types/src/{global-cli/helpers/autogeneratedFileMessage.d.ts → helpers/cli/autoGeneratedFileDisclaimer.d.ts} +0 -0
@@ -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;
@@ -1,77 +0,0 @@
1
- import * as colors from 'colorette';
2
- export default function logo() {
3
- return (colors.bgMagentaBright(colors.black(`
4
- ,▄█▄
5
- ]█▄▄ ╓█████▌
6
- ▐██████▄ ▄█████▓╣█
7
- ║████████▄, , ,,▄,▄▄▄▓██████╬╬╣╣▌
8
- ╚███╣██████████▓▓▓▓██████████╩╠╬▓
9
- ╙█╬╬╬▓███████████████████████▒▓▌ `)) +
10
- colors.bgMagentaBright(colors.black(`
11
- ╙▓█▓██████████████████████████
12
- ╚██████▀███████████`) +
13
- colors.greenBright(`╩█▓▌`) +
14
- colors.black(`▐▓████▄
15
- '║█████`) +
16
- colors.greenBright(`\`╣█Γ║`) +
17
- colors.black(`████████▄▄φ▓█████▌
18
- ║█████████████████████▓█████▌
19
- █████████████▓▓████████████ `)) +
20
- colors.bgMagentaBright(colors.black(`
21
- ║█████████████████████████
22
- ]█████████████████████████
23
- ,▓██████████████████████████
24
- ▓█████████████████████████████µ `)) +
25
- colors.bgMagentaBright(colors.black(`
26
- ▐███████████████████████████████▄▄
27
- ║█████████████████████████████████╬╬╣▓
28
- ,╔╦║███████████████████████████████████▓╬╬╣
29
- ,≥≥⌠░░░╠▓████████████████████████████████████▓▓
30
- ,;=-',▄█████████████████████████████████████████▓ `)) +
31
- colors.bgGreen(colors.magenta(`
32
-
33
-
34
-
35
- ██████╗ ███████╗██╗ ██╗ ██████╗██╗ ██╗██╗ ██████╗
36
- ██╔══██╗██╔════╝╚██╗ ██╔╝██╔════╝██║ ██║██║██╔════╝
37
- ██████╔╝███████╗ ╚████╔╝ ██║ ███████║██║██║
38
- ██╔═══╝ ╚════██║ ╚██╔╝ ██║ ██╔══██║██║██║
39
- ██║ ███████║ ██║ ╚██████╗██║ ██║██║╚██████╗
40
- ╚═╝ ╚══════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═════╝
41
-
42
- `)));
43
- }
44
- export function basicLogo() {
45
- return (`
46
- ,▄█▄
47
- ]█▄▄ ╓█████▌
48
- ▐██████▄ ▄█████▓╣█
49
- ║████████▄, , ,,▄,▄▄▄▓██████╬╬╣╣▌
50
- ╚███╣██████████▓▓▓▓██████████╩╠╬▓
51
- ╙█╬╬╬▓███████████████████████▒▓▌
52
- ╙▓█▓██████████████████████████
53
- ╚██████▀███████████╩█▓▌▐▓████▄
54
- '║█████\`╣█Γ║████████▄▄φ▓█████▌
55
- ║█████████████████████▓█████▌
56
- █████████████▓▓████████████
57
- ║█████████████████████████
58
- ]█████████████████████████
59
- ,▓██████████████████████████
60
- ▓█████████████████████████████µ
61
- ▐███████████████████████████████▄▄
62
- ║█████████████████████████████████╬╬╣▓
63
- ,╔╦║███████████████████████████████████▓╬╬╣
64
- ,≥≥⌠░░░╠▓████████████████████████████████████▓▓
65
- ,;=-',▄█████████████████████████████████████████▓
66
-
67
-
68
-
69
- ██████╗ ███████╗██╗ ██╗ ██████╗██╗ ██╗██╗ ██████╗
70
- ██╔══██╗██╔════╝╚██╗ ██╔╝██╔════╝██║ ██║██║██╔════╝
71
- ██████╔╝███████╗ ╚████╔╝ ██║ ███████║██║██║
72
- ██╔═══╝ ╚════██║ ╚██╔╝ ██║ ██╔══██║██║██║
73
- ██║ ███████║ ██║ ╚██████╗██║ ██║██║╚██████╗
74
- ╚═╝ ╚══════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═════╝
75
-
76
- `);
77
- }
@@ -1,10 +0,0 @@
1
- export const cliPrimaryKeyTypes = ['bigserial', 'serial', 'uuid'];
2
- export const cliDefaultProjectPath = '.';
3
- export const cliDefaultConfigPath = 'src/conf.js';
4
- export const cliDefaultDbPath = 'src/db.js';
5
- export const cliDefaultTypesPath = 'src/types.js';
6
- export const cliDefaultModelsPath = 'src/app/models.js';
7
- export const cliDefaultSerializersPath = 'src/app/serializers.js';
8
- export const cliDefaultServicesPath = 'src/app/services.js';
9
- export const cliDefaultModelSpecsPath = 'spec/uspec/models.js';
10
- export const cliDefaultFactoriesPath = 'spec/factories.js';
@@ -1,30 +0,0 @@
1
- import * as readline from 'readline';
2
- const input = process.stdin;
3
- export default class Prompt {
4
- question;
5
- cb = null;
6
- constructor(question) {
7
- this.question = question;
8
- }
9
- async run() {
10
- this.init();
11
- return new Promise(accept => {
12
- this.cb = accept;
13
- });
14
- }
15
- init() {
16
- const rl = readline.createInterface({
17
- input: process.stdin,
18
- output: process.stdout,
19
- });
20
- rl.question(this.question + '\n', res => {
21
- this.cb?.(res);
22
- rl.close();
23
- });
24
- }
25
- close = () => {
26
- input.setRawMode(false);
27
- input.pause();
28
- process.exit(0);
29
- };
30
- }